<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<title>Exported from Notepad++</title>
<style type="text/css">
span {
	font-family: 'Courier New';
	font-size: 10pt;
	color: #000000;
}
.sc0 {
}
.sc1 {
	font-style: italic;
	color: #0000FF;
}
.sc2 {
	font-style: italic;
	color: #0000FF;
}
.sc4 {
	color: #8000FF;
}
.sc5 {
	font-weight: bold;
	font-style: italic;
	color: #0000FF;
}
.sc6 {
	font-weight: bold;
	color: #008000;
}
.sc8 {
	font-weight: bold;
	font-style: italic;
	color: #008000;
}
.sc10 {
	font-weight: bold;
	color: #0080FF;
}
.sc11 {
}
.sc14 {
	color: #8080FF;
}
</style>
</head>
<body>
<div style="float: left; white-space: pre; line-height: 1; background: #FFFFFF; "><span class="sc2">// ================================================== //</span><span class="sc0">
</span><span class="sc2">// ============ TUTORIELS BEBOP 1.0 ================= //</span><span class="sc0">
</span><span class="sc2">// ================================================== //</span><span class="sc0">

</span><span class="sc2">// Module bopwatch</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">include</span><span class="sc0"> </span><span class="sc10">&lt;</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">bop</span><span class="sc10">&gt;</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">define</span><span class="sc0"> </span><span class="sc8">N</span><span class="sc0"> </span><span class="sc4">4</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">define</span><span class="sc0"> </span><span class="sc11">trace1</span><span class="sc0"> </span><span class="sc14">"trace01"</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">define</span><span class="sc0"> </span><span class="sc11">trace2</span><span class="sc0"> </span><span class="sc14">"trace02"</span><span class="sc0">

</span><span class="sc2">// Autre exemple, pour tracer : rediriger le channel stderr d'une instance du module bopwatch :</span><span class="sc0">
</span><span class="sc5">external</span><span class="sc0"> </span><span class="sc11">tracer</span><span class="sc0"> </span><span class="sc14">"$(BOPWATCH_EXE) 2&gt; $(trace2)"</span><span class="sc0">
    </span><span class="sc6">def</span><span class="sc0"> </span><span class="sc11">print</span><span class="sc0"> </span><span class="sc14">"DISPLAY"</span><span class="sc0"> 
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">external</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc8">TutorielBopWatch</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">])</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">s0</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc2">// utilisation du bloc tracer</span><span class="sc0">
    </span><span class="sc10">$</span><span class="sc11">tracer</span><span class="sc10">.</span><span class="sc11">print</span><span class="sc10">(</span><span class="sc14">"TRACER : Premier bit de e : %b, e tout entier : %$(N)b"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">]);</span><span class="sc0">

    </span><span class="sc2">// Methode display : sans chaine de format</span><span class="sc0">
    </span><span class="sc10">$</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">display</span><span class="sc10">(</span><span class="sc14">"Valeur de N = $(N)"</span><span class="sc10">);</span><span class="sc0">

    </span><span class="sc2">// Methode display avec chaine de format : affichage de e comme entier, bits, entier signé</span><span class="sc0">
    </span><span class="sc10">$</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">display</span><span class="sc10">(</span><span class="sc14">"e = %$(N)n , %$(N)b, %$(N)d"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">]);</span><span class="sc0">
    
    </span><span class="sc2">// method send : envoyer à un process externe au lieu d'afficher sur stderr</span><span class="sc0">
    </span><span class="sc10">$</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">send</span><span class="sc10">(</span><span class="sc14">"cat &gt; $(trace1)"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc14">"SEND : e[0] = %b"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]);</span><span class="sc0">
    </span><span class="sc2">// creation d'une instance du process shell 'cat &gt; $(trace1)'</span><span class="sc0">

    </span><span class="sc2">// Exemple : Production à la volée de code latex</span><span class="sc0">
    </span><span class="sc10">$</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">send</span><span class="sc10">(</span><span class="sc14">"bopsimu echo.bop -latex &gt; result.tex"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc14">"%$(N)b"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">]);</span><span class="sc0">

    </span><span class="sc2">// Method wpipe : pareil que pipe, sauf qu'on passe par une couche de display avant</span><span class="sc0">
    </span><span class="sc11">s0</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">$</span><span class="sc11">bopwatch</span><span class="sc10">.</span><span class="sc11">wpipe</span><span class="sc10">(</span><span class="sc14">"cat"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc14">"%b"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">e</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]);</span><span class="sc0"> </span><span class="sc2">// cat : simple echo</span><span class="sc0">
    </span><span class="sc1">/* Vue comme ça, cat est une application qui respecte le protocole pipe01 ! */</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">
</span></div></body>
</html>
